frame.window= function (){

	return{
		top:function(){
				var w = window;
				return w.top;
			},
			
		openDialog:function(){
			var dd=$("<div id='dd'></div>");
			dd.dialog({
				    title: 'My Dialog',
				    width: 400,
				    height: 200,
				    closed: false,
				    cache: false,
				    modal: true
				});
		},
		
		openWindow:function(url){
			var iframeId = "xxxx";
			setparam =function(){
				$('#'+iframeId)[0].contentWindow._parent_=dd;
				$('#'+iframeId)[0].contentWindow._openParent_= window;
			};

			var content = "<iframe id='" + iframeId
			+ "' frameborder='0' style='width:100%;height:99%' src='"+frame.fullUrl(url)+"' onload='setparam()'></iframe>";
			var dd=$("<div id='dd'></div>");
			dd.window({
					title: null,
					content:content,
				    fit:true,
				    modal: true,
				    onClose:function(){
				    	dd.window("destroy");
				    }
				});
		},
		
		closeWindow:function(){
			window._parent_.window("destroy");
		},
		
		refresh:function(params){
			if(!$.isEmptyObject(params)){
				var oldParams = {};
				var seg = window.location.search.replace(/^\?/, '').split('&');
		        var len = seg.length, i = 0, s;
		        for (; i < len; i++) {
		            if (!seg[i]) { continue; }
		            s = seg[i].split('=');
		            oldParams[s[0]] = s[1];
		        }
				var newParams = jQuery.extend({}, oldParams, params);
				var url = window.location.href.split("?")[0] +"?";
				for (var name in newParams) {
					url += name +"="+newParams[name]+"&";
		        }
				window.location.href = url;
			} else {
				self.location.reload();
			}
		},
		
		getOpenParent:function(){
			if(window._openParent_==null){
				return window.parent;
			} else {
				return window._openParent_;
			}
		}
	};
}();